package com.example.app.feign.inter.controller;

import com.example.app.feign.inter.entity.Person;
import com.example.app.feign.inter.service.HelloServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangzhuangzhuang
 * @DESC: 创建一个RestClientController来实现对Feign客户端的调用，使用@Autowired直接注入
 * 上面定义的HelloServiceFeign实例，并在postPerson函数中调用这个绑定了hello-service服务接口的客户端向该服务
 * 发起/hello接口的调用
 * @date 2022-02-25 11:20
 */
@RestController
public class RestClientController {

	@Autowired
	private HelloServiceFeign client;

	@RequestMapping(value = "/client/postPerson", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
	public Person postPerson(String name){
		return client.postPerson(name);
	}

	@RequestMapping(value = "/client/getHost", method = RequestMethod.GET)
	public String getHost(String name){
		return client.getHost(name);
	}


}